/*
 * File name: CCamera.cpp
 * Date:      2010
 * Author:    Tom Krajnik 
 */
#include "CCamera.h"
#include <stdio.h>
#include <stdlib.h>

//-----------------------------------------------------------------------------
CCamera::CCamera()
{
	gain = exposition = 0;
	width = height = 0;
	fileNum = 0;
	return;
}

CCamera::~CCamera()
{
}

int CCamera::init(const char *deviceName)
{
	char fileName[1000];
        width = 640;
        height = 480;
	strcpy(directory,deviceName);
	sprintf(fileName,"%s/0000.bmp",directory);
	FILE* file = fopen(fileName,"r");
	if (file == NULL){
		fprintf(stderr,"File %s not found.\n",fileName);
		return -1;
	}
	return 0;
}

int CCamera::renewImage(CRawImage* image)
{
	char fileName[1000];
	sprintf(fileName,"%s/%04i.bmp",directory,fileNum);
	if (image->loadBmp(fileName)) fileNum++; else fileNum=0;
	return 0; 
}

int CCamera::getGain()
{
	fprintf(stderr,"Gain setting not supported by dummy camera.\n");
	return 0;
}

int CCamera::getExposition()
{
	fprintf(stderr,"Exposure setting not supported by dummy camera.\n");
	return 0;
}

int CCamera::getBrightness()
{
	fprintf(stderr,"Brightness setting not supported by dummy camera.\n");
	return 0;
}

void CCamera::setGain(int value)
{
	fprintf(stderr,"Gain setting not supported by dummy camera.\n");
}

void CCamera::setExposition(int exp)
{
	fprintf(stderr,"Exposure  setting not supported by dummy camera.\n");
}

void CCamera::setBrightness(int val)
{
	fprintf(stderr,"Brightness setting not supported by dummy camera.\n");
}
